package com.itqf.utils;

import java.security.KeyPair;

/**
 * projectName: gpshop
 *
 * @author: 赵伟风
 * time: 2021/7/21 14:18
 * description:
 */
public class UseEncryp {


    public static void main(String[] args) throws Exception {

        //1.对称性加密
        String key = "password";
        String content = "abcde";
        String data = EncryptUtils.DESencode(content, key);
        System.out.println("data = " + data);
        System.out.println("----------");
        String str = EncryptUtils.DESdecode(data, key);
        System.out.println(str);

        //2.非对称型加密
        //1.生成钥匙对
        KeyPair keyPair = EncryptUtils.generateKeyPair();

        String encrypt = EncryptUtils.encrypt(content, keyPair.getPublic());
        System.out.println("秘文 = " + encrypt);

        String decrypt = EncryptUtils.decrypt(encrypt, keyPair.getPrivate());
        System.out.println("decrypt = " + decrypt);


    }

}
